package cut;

public class LogicStructure {

    public int sequence(int a, int b) {
        return a + b;
    }

    public boolean soloIf(int op) {
        if (op > 0)
            return true;
        return false;
    }

    public boolean soloIfChar(char op) {
        if (op > 'a')
            return true;
        return false;
    }

    public boolean ifElse(int op) {
        if (op > 18)
            return true;
        else
            return false;
    }

    public String multipleIf(int op) {
        if (op % 15 == 0)
            return "FizzBuzz";
        else if (op % 5 == 0)
            return "Buzz";
        else if (op % 3 == 0)
            return "Fizz";
        else
            return Integer.toString(op);
    }

    // 单循环结构
    public int whileLoop (int num) {
        while (num > 0) {
            num--;
        }
        return num;
    }

    public void forLoop(int op){
        for(int i=0;i<=op;i++){
            System.out.println(i);
        }
    }

    public String whileDo(int op,boolean exit){
        if(exit)
            return "NoWhile";
        while(op>0){
            op-=1;
            exit=!exit;
        }
        if(exit)
            return "true";
        else
            return "false";
    }

    //课堂双菱问题，可区分语句覆盖和分支覆盖
    public int doubleDiamond(int num1,int num2,int num3){
        if((num1>1)&&(num2==0))
            num3/=num1;
        if((num1==2)||(num3>1))
            num3+=1;
        return num3;
    }
}
